package com.ilink.teacherservice.controller.xiaolian;
import com.ilink.ilinkcommon.domain.R;
import com.ilink.ilinkcommon.log.method.MethodLog;
import com.ilink.teacherservice.service.xiaolian.XiaolianIndexService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/teacher/xiaolian_index")
public class XiaolianIndexController {

    @Autowired
    XiaolianIndexService xiaolianIndexService;
    @MethodLog
    @PostMapping("/chat_test")
    public R chatTestIndex(String query) {
        try {
            return xiaolianIndexService.normalChat(query);
        } catch (Exception e) {
            return R.error("对话失败");
        }
    }

    @MethodLog
    @PostMapping("/retrieve_test")
    public R retrieveTestIndex(String query) {
        try {
            return xiaolianIndexService.testRetrieve(query);
        } catch (Exception e) {
            return R.error("测试检索失败"+e);
        }
    }

    // 小链雏形demo
    @MethodLog
    @PostMapping("/agent-demo")
    public R AgentDemoIndex(String query) {
        try {
            return xiaolianIndexService.agentDemo(query);
        } catch (Exception e) {
            return R.error("小链demo失败"+e);
        }
    }
}
